<template>
  <div>
    <AdminHeader></AdminHeader>
    <AdminAside></AdminAside>
    <div class="content-box" :class="{ 'content-collapse': collapse }">
      <router-view></router-view>
      <adminMovies v-if="store.state.isHome"></adminMovies>
    </div>
  </div>
</template>

<script setup>
import AdminHeader from '../components/Admin/AdminHeader.vue'
import AdminAside from '../components/Admin/AdminAside.vue'
import adminMovies from '../views/AdminMovies.vue'
import axios from 'axios'
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useStore } from 'vuex'
const router = useRouter()
const store = useStore()

const collapse = ref(false)

onMounted(() => {
  if (document.documentElement.clientWidth > document.documentElement.clientHeight) {
    router.push('/AdminHome')
  } else {
    router.push('/PhoneAdminHome')
  }
  store.commit('setIsHome', true)
  axios
    .get('/api/admin/getAdminAllInfoByAid/' + sessionStorage.getItem('aid'))
    .then((res) => {
      if (res.data[0].aname === '超级管理员') {
        store.commit('setAdmin', true)
      } else {
        store.commit('setAdmin', false)
      }
    })
    .catch(() => {
      ElMessage.warning('角色权限获取失败！')
    })
})
</script>

<style lang="scss" scoped>
@import '@/assets/scss/adminHome.scss';
</style>
